//
//  STTabBar.m
//  ShaBaoOnLine
//
//  Created by huang yong on 16/7/7.
//  Copyright © 2016年 com.ShaBaoOnline.www. All rights reserved.
//

#import "STTabBar.h"
#define  PYControllCount 4
@interface STTabBar ()

@property (nonatomic, strong)UIButton *addBtn;

@end

@implementation STTabBar

- (instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        UIButton *addBtn = [UIButton buttonWithType:UIButtonTypeCustom];
//        [addBtn setBackgroundImage:[UIImage imageNamed:@"post_normal"] forState:UIControlStateNormal];
//        [addBtn setBackgroundImage:[UIImage imageNamed:@"post_normal"] forState:UIControlStateHighlighted];
//        [self setBackgroundColor:[UIColor whiteColor]];
//        [addBtn setBackgroundImage:[UIImage imageNamed:@"post_normal"] forState:UIControlStateNormal];
//        [addBtn setBackgroundImage:[UIImage imageNamed:@"post_normal"] forState:UIControlStateHighlighted];
//        self.addBtn = addBtn;
//       
//        [addBtn addTarget:self action:@selector(addBtnAction:) forControlEvents:UIControlEventTouchUpInside];
//        
//        [self addSubview:addBtn];
//        NSLog(@"%f====",addBtn.frame.size.width);
    }
    return self;
}

//- (void)layoutSubviews{
//    [super layoutSubviews];
//    // 计算宽度
//    CGFloat childW = self.width / (PYControllCount + 1);
//    self.addBtn.width = childW - 20;
//    self.addBtn.height = 49;
//    
//    // 添加plusBtn的位置
//    self.addBtn.x = ([UIScreen mainScreen].bounds.size.width - childW) * 0.5;
//    self.addBtn.y = - self.height/2;
//    
//    // 引出下标
//    NSInteger index = 0;
//    // 判断是否为控制器按钮
//    for (UIView *child in self.subviews) {
//        Class class = NSClassFromString(@"UITabBarButton");
//        if ([child.class isSubclassOfClass:class]) {
//            child.x = index * childW;
//            child.width = childW;
//            index++;
//            if (index == 2) {
//                index ++;
//            }
//        }
//    }
//    
//    [self bringSubviewToFront:self.addBtn];
//}
//
//- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event{
//    if (self.isHidden == NO) {
//        CGPoint newP = [self convertPoint:point toView:self.addBtn];
//        
//        if ([self.addBtn pointInside:newP withEvent:event]) {
//            return self.addBtn;
//        } else {
//           return [super hitTest:point withEvent:event];
//        }
//    } else {
//        return [super hitTest:point withEvent:event];
//    }
//}
//
//- (void)addBtnAction:(UIButton *)btn{
//    if ([self.mydelegate respondsToSelector:@selector(addBtnClickHandler)]) {
//        [self.mydelegate addBtnClickHandler];
//    }
//}

@end
